package com.aruba.download.service.impl;

import com.aruba.download.service.UploadService;
import com.aruba.download.utils.FastDFSClient;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

@Service
public class UploadServiceImpl implements UploadService {

    @Override
    public String upload(MultipartFile file) throws IOException {
        String[] ret = FastDFSClient.uploadFile(file.getInputStream(), file.getName());
        StringBuilder stringBuilder = new StringBuilder();
        for (String item : ret) {
            stringBuilder.append(File.separator).append(item);
        }
        return stringBuilder.toString();
    }

}
